<!doctype html>
<html>
<head>
  <meta charset="utf-8">
</head>
<body>
<embed id="plugin" width="0" height="0" type="application/x-switch"></embed>
<script>
  var plugin = document.getElementById('plugin');
  var quickLaunchFolder = localStorage.getItem('quick_launch_folder');
  var startMenuFolder = localStorage.getItem('start_menu_folder');
  var desktopFolder = localStorage.getItem('desktop_folder');
  var defaultUserDataPath = localStorage.getItem('default_user_data_path');

  // Cache folders.
  if (!quickLaunchFolder || !plugin.validPath(quickLaunchFolder)) {
    quickLaunchFolder = plugin.getQuickLaunchFolder();
    localStorage.setItem('quick_launch_folder', quickLaunchFolder);
  }

  if (!startMenuFolder || !plugin.validPath(startMenuFolder)) {
    startMenuFolder = plugin.getStartProgramFolder();
    localStorage.setItem('start_menu_folder', startMenuFolder);
  }

  if (!desktopFolder || !plugin.validPath(desktopFolder)) {
    desktopFolder = plugin.getDesktopFolder();
    localStorage.setItem('desktop_folder', desktopFolder);
  }

  if (!defaultUserDataPath || !plugin.validPath(defaultUserDataPath)) {
    defaultUserDataPath = plugin.getDefaultDataPath();
    localStorage.setItem('default_user_data_path', defaultUserDataPath);
  }
  
  var paths = {
    quickLaunchFolder: quickLaunchFolder,
    startMenuFolder: startMenuFolder,
    folderOfUsersData: plugin.getUserDataFolder(),
    desktopFolder: desktopFolder,
    defaultUserDataPath: defaultUserDataPath
  };

  // Show option page when first run.
  if (!localStorage.getItem('first_run_flag')) {
    localStorage.setItem('first_run_flag', true);
    chrome.tabs.create({
      url: 'options.html'
    });
  }
</script>
</body>
</html>